package common.Enums;

import common.Exceptions.OperatorTypeException;

public enum OperatorType 
{
	SUM('+'),
	SUBTRACT('-'),
	DIVISION('/'),
	MULTIPLICATION('*'),
	ELEVATED('^');
	
	private char operator;
	
	private OperatorType(char operator)
	{
		this.operator = operator;
	}
	
	public char getOperator()
	{
		return operator;
	}
	
	public static OperatorType getOperatorEnum(char operator) throws OperatorTypeException
	{
		OperatorType operatorType = null;
		
		for(OperatorType operatorTp : OperatorType.values())
			if(operatorTp.getOperator() == operator)
				operatorType = operatorTp;
		
		if(operatorType == null)
			throw new OperatorTypeException("The operator " + operator + " is not a valid operator.");
		
		return operatorType;
	}
	
}
